package com.company;

import java.util.*;

/**
 * 学生信息管理（学生英文名获取对应学生详细信息）
 * @author 关敬元
 * @Description
 * @date 2019/11/28
 */
public class SyudentsInfoMgr {
    public static void main(String[] args) {
     Students stu1=new Students("小明","男");
     Students stu2=new Students("小红","女");
     Students stu3=new Students("小李","男");

     Map map=new HashMap();
     map.put("Tom",stu1);
     map.put("Jack",stu2);
     map.put("Jesson",stu3);

        System.out.println("一共有"+map.size()+"对学生进入了阿里巴巴公司。");
        System.out.println("他们是：");
        Set set=map.entrySet();
        for (Object obj:set){
            Map.Entry me = (Map.Entry) obj;
            String key = (String)me.getKey();
            Students students = (Students) me.getValue();
            System.out.println(key+"-"+students.getName()+"-"+students.getSex());
        }
        //实现获取特定英文名称对应的学生信息
        System.out.println("-----------------------");
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入要查找的学生英文名：");
        String name = sc.next();
        if (map.containsKey(name)){
            //在Map中找到了相应的Key,则根据key去获取相应的value（学生对象）
            Students students=(Students) map.get(name);
            System.out.println("该学生全部信息如下：");
            System.out.println(name+"-"+students.getName()+"-"+students.getSex());
        }else {
            System.out.println("没有该学生！");
        }
    }
}
